package com.xindaoapp.happypet.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;

import com.xindaoapp.happypet.R;

public class MySearchAdapter extends BaseAdapter implements ListAdapter {
	private final Context mContext;
	private final String[] str;

	public MySearchAdapter(Context mContext, String history) {
		super();
		this.mContext = mContext;
		str = history.split("%$");
	}

	@Override
	public int getCount() {
		return str.length / 2;
	}

	@Override
	public Object getItem(int position) {
		return str[position * 2];
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View arg1, ViewGroup arg2) {
		View view = View.inflate(mContext, R.layout.list_item_search, null);
		TextView tv = (TextView) view.findViewById(R.id.header);
		tv.setText(str[position * 2]);
		return view;
	}

}
